import { Controller, Get, Delete, Param, Post, Body, Put } from "@nestjs/common";
import { UserService } from "./user.service";
import { ApiTags, ApiOperation } from "@nestjs/swagger";
import { UserDto } from "./user.dto";

@Controller('user')
@ApiTags('用户')
export class UserController{
    constructor(
        private readonly userService:UserService
    ){}

    @Get()
    @ApiOperation({summary:'查询用户'})
    async find(){
        return await this.userService.find()
    }

    @Delete(':id')
    @ApiOperation({summary:'根据id删除用户'})
    async remove(@Param('id') userId){
        return await this.userService.remove(userId)
    }

    @Post()
    @ApiOperation({summary:'更改用户'})
    async update(@Body() user:UserDto){
        return await this.userService.update(user);
    }
    
    @Put()
    @ApiOperation({summary:'新增用户'})
    async add(@Body() user:UserDto){
        return await this.userService.add(user)
    }
}